package com.example.extenddemo.controller;

import com.example.extenddemo.format.FormatHandle;
import com.example.extenddemo.utils.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName FormatController
 * @Description TODO
 * @Author 郭敖
 * @Date 2024年06月28日 22:05
 * @Version 1.0
 */
@RequestMapping("/format")
@RestController
public class FormatController {

    @PostMapping("/formatStr")
    public Result<String> formatStr(String content) {
        String formatStr = handleString(content, (str) -> String.format("formatStr:%s", str));
        return Result.Success(formatStr);
    }

    private String handleString(String format, FormatHandle<String> formatHandle){
        return formatHandle.handle(format);
    }
}
